<template>
	<div class="app_container">
		<home-page @push="setPage" ref="home" v-if="cur_page == 'home'" />
		<manage-page @push="setPage" v-if="cur_page == 'manage'"></manage-page>
		<login-page @push="setPage" v-if="cur_page == 'login'"></login-page>
	</div>
</template>

<script>
import homePage from './components/homePage.vue'
import loginPage from './components/login.vue'
import managePage from './components/managePage'
export default {
	name: 'App',
	components: {
		homePage,
        loginPage,
        managePage
	},
    data() {
        return {
            cur_page: 'manage',
            userInfo: {},
        }
    },
    created(){
        this.userInfo = JSON.parse(window.sessionStorage.getItem('userInfo'))
        if(!this.userInfo || !this.userInfo.id) {
            this.cur_page = 'login'
        }
    },
    methods:{
        setPage(page) {
            this.cur_page = page
            if (page == 'home') {
                this.$nextTick(()=>{
                    this.$refs.home.updateForm()
                });
            }
    }}
}
</script>

<style>
body {
	margin: 0;
}
.el-message-box {
    width: auto!important;
}
.app_container {
	min-height: 100vh;
	width: 100vw;
	overflow-y: scroll;
}
</style>
